﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;

namespace DreametryMIS
{
    public static class promptDone
    {   //Arro
        public static string x;
        public static ContextMenuStrip contxtmenu;
        public static string ShowDialog(string text, string caption,String taskname, String nickname)
        {   /*Arro
            //String path;
            TextBox textBox;
            */
            Form prompt = new Form()
            {
                Width = 425,
                Height = 210,
                FormBorderStyle = FormBorderStyle.FixedDialog,
                BackColor = System.Drawing.Color.WhiteSmoke,
                Font = new Font("Segoe UI", 10, FontStyle.Regular),
                Text = caption,
                StartPosition = FormStartPosition.CenterScreen
            };
            Label textLabel = new Label() { Left = 10, Top = 10, Text = text, Width = 400, Font = new Font("Segoe UI", 10, FontStyle.Bold), };
            TextBox textBox = new TextBox() { Left = 10, Top = 40, Width = 400, Height = 85, Multiline = true, AcceptsReturn=true,BorderStyle = BorderStyle.FixedSingle };
            /*Arro
            FileSystemWatcher systemwatch = new FileSystemWatcher() { Path = @"\\server-pc\Dropbox\_____Codiga\_____AI and PSD Files\____TASKS IN PROGRESS\" + nickname + @"\logs\", EnableRaisingEvents = true };
           
            NotifyIcon notify = new NotifyIcon() { Text = "Comment", ContextMenuStrip = contxtmenu, Icon = DreametryMIS.Properties.Resources.comments, Visible = true };
            notify.ContextMenuStrip = prompt.ContextMenuStrip;
            contxtmenu = new ContextMenuStrip() { Name = "contextMenuStrip", Text = "Comment" };
            //contxtmenu.Opening += cms_Opening;
            ToolStripMenuItem showCommentToolStripMenuItem;
         
            showCommentToolStripMenuItem = new ToolStripMenuItem("Show") { Name = "showCommentToolStripMenuItem", Text = "Show Comment", };
            showCommentToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
         
         
            contxtmenu.Items.AddRange(new ToolStripItem[] { showCommentToolStripMenuItem });
            contxtmenu.Items.Add(showCommentToolStripMenuItem);
            showCommentToolStripMenuItem.Text = "Show Comment";
            prompt.ContextMenuStrip = contxtmenu;
            Arro*/
            Button confirmation = new Button()
            {
                Text = "Ok",
                Left = 310,
                Width = 100,
                Height =30,
                FlatStyle = FlatStyle.Flat,
                Top = 140
            };
            confirmation.FlatAppearance.BorderSize = 0;
            //Arro
            // systemwatch.Created += (sender, e) =>
            //{
            //   
            //    path = e.FullPath;
            //    
            //    String result = System.IO.Path.GetFileName(path);
            //    y = Path.GetDirectoryName(result.TrimEnd(Path.DirectorySeparatorChar));
            //    x = Path.GetFileName(result);
            // ###################################       
            //       if (File.Exists(path))
            //       {
            //           File.Delete(path);
            //       }
            //#################################
            //    MessageBox.Show(path);
            //
            //};Arro
            confirmation.Click += (sender, e) => {
               
                create(textBox.Text , nickname);

                prompt.Close(); };
            prompt.Controls.Add(textBox);
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(textLabel);
            prompt.AcceptButton = confirmation;
            
            return prompt.ShowDialog() == DialogResult.OK ? textBox.Text : textBox.Text;
        }
       
        public static void create(String text,String nickname)
        {
           
            String asd = @"\\server-pc\Dropbox\_____Codiga\_____AI and PSD Files\____TASKS IN PROGRESS\" + nickname + @"\"+ text;
            if (!File.Exists(asd))
            {
                try
                {
                    using (StreamWriter sw = File.CreateText(asd))
                    {
                        sw.WriteLine("");
                    }
                }
                catch { }

            }
        }
    }
}
